'use strict';
exports.main = async (event, context) => {
    //event为客户端上传的参数
    console.log('event : ', event)

    const db = uniCloud.database(); //代码块为cdb
    const collection = db.collection('notice');

    let queryStringParameters = event.queryStringParameters
    let res = await collection.add({
        author: queryStringParameters['author'],
        title: queryStringParameters['title'],
				pubTime: queryStringParameters['pubTime'],
				type: queryStringParameters['type'],
				imgUrl: queryStringParameters['imgUrl'],
				content: queryStringParameters['content'],
				userId: queryStringParameters['userId'],
    })
    //返回数据给客户端
    return {
        mesg: '新增成功',
        code: 200
    }
};